/*
 * Copyright (C) 2006  Antonie Struyk
 *
 * This file is part of MusicFlashCards.
 *
 *    Freetar Hero is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    MusicFlashCards is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with MusicFlashCards; if not, write to the Free Software
 *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

package com.antonstruyk.musicflashcards;

import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Graphics;

/**
 *
 * @author Anton
 */
public class KeyboardDisplayPanel extends JPanel{
    
    protected static final int WHITE_KEY_WIDTH = 20;
    protected static final int WHITE_KEY_HEIGHT = 100;
    protected static final int BLACK_KEY_WIDTH = 10;
    protected static final int BLACK_KEY_HEIGHT = 60;
    
    /** Creates a new instance of KeyboardDisplayPanel */
    public KeyboardDisplayPanel() {
        super();
        
        this.setBackground(Color.WHITE);
    }
    
    public void paintComponent(Graphics g){
        super.paintComponent(g);
        
        //Draw the white keys
        for(int i = 0; i < 7; i++){
            drawWhiteKey(i * WHITE_KEY_WIDTH + 1, 4, g);
        }
        
        //Draw the black keys
        for(int i = 0; i < 2; i++){
            drawBlackKey(i * WHITE_KEY_WIDTH + WHITE_KEY_WIDTH -  BLACK_KEY_WIDTH / 2 + 1, 4, g);
        }
        for(int i = 3; i < 6; i++){
            drawBlackKey(i * WHITE_KEY_WIDTH + WHITE_KEY_WIDTH -  BLACK_KEY_WIDTH / 2 + 1, 4, g);
        }
    }
    
    protected void drawWhiteKey(int x, int y, Graphics g){
        g.setColor(Color.BLACK);
        g.drawRect(x, y, WHITE_KEY_WIDTH, WHITE_KEY_HEIGHT);
    }
    
    protected void drawBlackKey(int x, int y, Graphics g){
        g.setColor(Color.BLACK);
        g.fillRect(x, y, BLACK_KEY_WIDTH, BLACK_KEY_HEIGHT);
    }
}
